package com.yan.yjhTest.jvm.reference;

import java.lang.ref.WeakReference;

/**
 * 强、软、弱、虚引用
 * @author yan
 */
public class Reference {

    /*ReferenceQueue<String> referenceQueue = new ReferenceQueue<String>();
    String str = new String("abc");
    SoftReference<String> softReference = new SoftReference<String>(str, referenceQueue);
    str = null;

    //Notify GC
    System.gc();
    System.out.println(softreference.get());

    Reference<? extends String> reference = referenceQueue.poll();
    System.out.println(reference);*/

    /**
     * 弱引用
     */
    String str = new String("abc");
    WeakReference<String> weakReference = new WeakReference<String>(str);
}
